<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>

<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-title" class="form-control" name="row[title]" type="text">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Content')}:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="c-content" data-rule="required" class="form-control editor" rows="5" name="row[content]" cols="50"></textarea>
        </div>
    </div>
  <!--   <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Openid')}:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="c-openid" class="form-control " rows="5" name="row[openid]" cols="50"></textarea>
        </div>
    </div> -->
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Typelist')}:</label>
        <div class="col-xs-12 col-sm-8">
                        
            <select  id="c-typelist" class="form-control selectpicker xiaohe" name="row[typelist]">
                {foreach name="typelistList" item="vo"}
                    <option value="{$key}" {in name="key" value="0"}selected{/in}>{$vo}</option>
                {/foreach}
            </select>

        </div>
    </div>

 <!--    <div class="form-group  dange">
        <label class="control-label col-xs-12 col-sm-2">输入昵称:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-title" class="form-control" name="row[title]" type="text" value="1">
        </div>
    </div> -->


	<div class="form-group" id="xuanze">
	    <label for="id_select" class="control-label col-xs-12 col-sm-2">接收用户:</label>
	    <div class="col-xs-12 col-sm-8">
			<select id="id_select" class="selectpicker bla bla bli col-xs-12 col-sm-8 openid" multiple data-live-search="true" name="openid[]">
			    {foreach name="user" item="vo"}
		                    <option value="{$vo.openid}" {in name="key" value="0"}selected{/in}>{$vo.nickname}----公司:《{$vo.ltdname}》----姓名:《{$vo.name}》</option>
		                {/foreach}
			    </optgroup>
		    </select>
		</div>
	</div>




  <!--   <div class="form-group " id="xuanze">
        <label class="control-label col-xs-12 col-sm-2">用户:</label>
        <div class="col-xs-12 col-sm-8">
                        
            <select  id="c-typelist" class="form-control selectpicker xiaohe" name="row[typelist]">
                {foreach name="user" item="vo"}
                    <option value="{$vo.openid}" {in name="key" value="0"}selected{/in}>{$vo.nickname}----公司:《{$vo.ltdname}》----姓名:《{$vo.name}》</option>
                {/foreach}
            </select>

        </div>
    </div>
 -->

    <script type="text/javascript">
    	//下拉搜索多选 QQ496631085
		 $(window).on('load', function () {
		           
		 $('.selectpicker').selectpicker({
		                'selectedText': 'cat'
		            });
		         
		   // $('.selectpicker').selectpicker('hide');
		        });
		  
 	 </script>

 





    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>


 	<script type="text/javascript">
        	
        	 $('#xuanze').hide();
          	$(".xiaohe").change(function(){
          		var typelist =$(".xiaohe").find("option:selected").val();

          		switch(typelist) {
						     case '0':
						        $('#xuanze').hide(); //群发所有人
						        break;
						     case '1':
						     	// alert('yhingcang');
						        $('#xuanze').show();//单个
						        break;
					        case '2':
						       $('#xuanze').hide();//群发注册用户
						        break;
						     default:
						        break;
						} 

          		// alert(typelist);
          		var openid=new Array();

          		$(".openid option:selected").each(function () {
          			openid.push($(this).val());
				});
				// console.log(openid);
          		// alert($(".openid").find("option:selected").serialize());

						 //    $.post("/api/yuye/send_yzm",{
							// 	// name:$("#name").val(),
							// 	tel:$("#tel").val(),
							// 	type:1
							// },function(data,status){
						 //        // alert("Data: " + data + "nStatus: " + status);
						 //        if(data.code>0){
						 //        	alert('验证码已发送');
						 //        }else{
						 //        	alert('发送失败：'+data.msg);
						 //        }
						 //    });
			});

            


            // var funcc = function () {
            //     alert('我爱编程')
            // }
            // var aa = document.getElementById('xiaohe')
            // aa.onclick = funcc

    </script>


</form>
